<template>
    <div class="top-btn" @click="backTop()">
      <div class="el-icon-arrow-up"></div>
      <p>TOP</p>
    </div>
</template>
<script>
export default {
  name: 'backTop',
  data () {
    return {

    }
  },
  components: {},
  methods: {
    backTop () {
      let back = setInterval(() => {
        if (document.body.scrollTop || document.documentElement.scrollTop) {
          document.body.scrollTop -= 100
          document.documentElement.scrollTop -= 100
        } else {
          clearInterval(back)
        }
      }, 20)
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.top-btn{
  width: 46px;
  height: 46px;
  position: fixed;
  bottom: 10%;
  right: 10%;
  background-color: #06AEA6;
  color: #fff;
  border-radius: 50%;
  text-align: center;
  cursor: pointer;
  .el-icon-arrow-up{
    width: 100%;
    height: 50%;
    font-size: 28px;
  }
  p{
    line-height: 8px;
  }
}
</style>
